package com.zhou.domain;

import lombok.Data;

@Data
public class Rusult {
    //返回结果编码
    private Integer code;
    //返回主要内容
    private Object data;
    //返回信息
    private String msg;

    public Rusult(Integer code, Object data, String msg) {
        this.code = code;
        this.data = data;
        this.msg = msg;
    }

    public Rusult() {
    }

    //无数据正常响应
    public static  Rusult success() {
        Rusult result = new Rusult();
        result.code = 1;
        return result;
    }
    //有数据正常响应
    public static  Rusult success(Object object) {
        Rusult result = new Rusult();
        result.data = object;
        result.code = 1;
        return result;
    }
    //报错
    public static  Rusult error(String msg) {
        Rusult result = new Rusult();
        result.msg = msg;
        result.code = 0;
        return result;
    }
}